package com.example.userservice.client;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;
import java.util.List;

@FeignClient(name = "COURSE-SERVICE")
public interface CourseClient {

    @PostMapping("/course/api/courses")
    String createCourse(@RequestBody Map<String, Object> requestBody);

    @GetMapping("/course/api/coursesinfo")
    List<Map<String, Object>> listCourses(@RequestParam("createdBy") int createdBy);

    @GetMapping("/course/api/chapters")
    List<Map<String, Object>> listChapters(@RequestParam("courseId") int courseId);

    @PostMapping("/course/api/chapters")
    String createChapter(@RequestBody Map<String, Object> requestBody);
    
    @DeleteMapping("/course/api/chapters/{chapterId}")
    String deleteChapter(@PathVariable int chapterId);

    @GetMapping("/course/api/courses")
    List<Map<String, Object>> listAllCourses();

    // 课件相关接口
    @PostMapping(value = "/course/api/material/save", consumes = "application/json")
    String saveMaterial(@RequestBody Map<String, Object> materialData);

    @GetMapping("/course/api/course/{courseId}/chapter/{chapterId}/materials")
    List<Map<String, Object>> getChapterMaterials(@PathVariable int courseId, @PathVariable int chapterId);

    @GetMapping("/course/api/material/{materialId}/info")
    Map<String, Object> getMaterialInfo(@PathVariable int materialId);

    @DeleteMapping("/course/api/material/{materialId}/delete")
    String deleteMaterial(@PathVariable int materialId);

    // ========== 管理员专用接口 ==========
    
    @PostMapping("/course/admin/api/courses/{courseId}/update")
    String adminUpdateCourse(@PathVariable int courseId, @RequestBody Map<String, Object> requestBody);

    @DeleteMapping("/course/admin/api/courses/{courseId}")
    String adminDeleteCourse(@PathVariable int courseId);

    @GetMapping("/course/admin/api/courses/{courseId}/details")
    Map<String, Object> getCourseDetails(@PathVariable int courseId);
}



